#ifndef __TERRAINACTIVEBLOCKHELPEROBJECT_H__
#define __TERRAINACTIVEBLOCKHELPEROBJECT_H__

#include <bigimage/renderitem.h>
#include <bigimage/geometry.h>
#include "helper/helperobject.h"

class CTerrainObject;
class CTerrainBlock;
class CTerrainActiveBlockHelperGeometry :public CGeometry {
public:
	CTerrainActiveBlockHelperGeometry(CTerrainObject* pTerrainObject);
	virtual ~CTerrainActiveBlockHelperGeometry();
	virtual void UpdateGeometry( list<CTerrainBlock*>* pTerrainBlockList, int32 nBlockCoordsX, int32 nBlockCoordsY, int32 nShape, int32 nSize );
	virtual CVertexBuffer* GetRenderBuffer();
	virtual CIndexBuffer* GetIndexBuffer();

public:
	int32 m_nTerrainActiveBlockHelperGeometryType;

protected:
	bool32 BuildActiveBlockGeometry( list<CTerrainBlock*>* pTerrainBlockList, int32 nCoordsX, int32 nCoordsY, vector<TV3C1T2> *pVertexList, vector<uint16> *pIndexList );
	
	Ref < CVertexBuffer*> m_rRenderBuffer;
	Ref< CIndexBuffer* >m_rIndexBuffer;
	CTerrainObject* m_pTerrainObject;
};


class CTerrainBrushGeometry: public CTerrainActiveBlockHelperGeometry{
public:
	CTerrainBrushGeometry(CTerrainObject* pTerrainObject);
	virtual ~CTerrainBrushGeometry();
	virtual void UpdateGeometry( list<CTerrainBlock*>* pTerrainBlockList, int32 nBlockCoordsX, int32 nBlockCoordsY, int32 nShape, int32 nSize );
};


class CTerrainActiveBlockHelperObject:public CHelperObject{
public:
    CTerrainActiveBlockHelperObject();
    virtual ~CTerrainActiveBlockHelperObject();
	void Init(CTerrainObject* pTerrainObject, int32 nBrushType, int32 nBrushSize);
	void SetBrushInfo( int32 nBrushType, int32 nBrushSize );
	virtual int32 GetRenderElementHandles(CRenderElement** vRenderElementHandle, int32 nMaxCount);
	list<CTerrainBlock*>* UpdateActiveBlock( int32 nBlockCoordsX, int32 nBlockCoordsY, int32 nSize, bool32 bForceUpdate = False );

private:
	CTerrainObject* m_pTerrainObject;
	Ref< CRenderItem* >m_rRenderItem;
	Ref< CTerrainActiveBlockHelperGeometry* >m_rTerrainHelperGeometry;
	int32 m_nBlockCoordsX;
	int32 m_nBlockCoordsY;
	int32 m_nBrushSize;
	int32 m_nBrushShapeType;

	list<CTerrainBlock*> m_vActiveBlockList;

};


#endif
